#include "Entity.h"

Entity::Entity()
{
	setMass(1.0);
}

Entity::Entity(Vec2d pos)
{
	this->pos = pos;
	setMass(1.0);
}

Entity::Entity(Vec2d pos, Vec2d vel, Vec2d accel)
{
	this->pos = pos;
	this->vel = vel;
	this->accel = accel;
	setMass(1.0);
}

Entity::Entity(Vec2d pos, Vec2d vel, Vec2d accel, float mass)
{
	this->pos = pos;
	this->vel = vel;
	this->accel = accel;
	setMass(mass);
}

void Entity::update()
{
	vel = vel + accel;
	pos = pos + vel;
}

void Entity::update(int timestep)
{
	vel = vel + (accel * timestep);
	pos = pos + (vel * timestep);
}

void Entity::setMass(float mass)
{
	if (mass != 0.0f)
	{
		this->mass = mass;
		this->invMass = 1.0f / mass;
	}
	else
	{
		this->mass = 1.0f;
		this->invMass = 1.0f;
	}
}

float Entity::getMass()
{
	return mass;
}

float Entity::getInvMass()
{
	return invMass;
}


